package com.jingtai.common.webfacade.response;


import com.jingtai.common.webfacade.error.ErrorEnum;
import lombok.Data;

import java.io.Serializable;

@Data
public class ResponseMsg implements Serializable {

    private Integer code;
    private Object data;
    private String message;
    private String status;

    public ResponseMsg() {
    }

    public static ResponseMsg failed(ErrorEnum errorEnum, String message) {
        ResponseMsg response = new ResponseMsg();
        response.setCode(errorEnum.getCode());
        response.setStatus("FAIL");
        response.setMessage(message);
        response.setData(errorEnum.getErrorDescription());
        return response;
    }

    public static ResponseMsg failed(String dataMsg, String message) {
        ResponseMsg response = new ResponseMsg();
        response.setCode(2);
        response.setStatus("FAIL");
        response.setMessage(message);
        response.setData(dataMsg);
        return response;
    }

    public static ResponseMsg failed(ErrorEnum errorEnum) {
        ResponseMsg response = new ResponseMsg();
        response.setCode(errorEnum.getCode());
        response.setStatus("SUCCESS");
        response.setMessage(errorEnum.getErrorDescription());
        response.setData(null);
        return response;
    }

}
